package com.bjb.vr.operation.controller;

import com.bjb.vr.common.ao.SysTenantAo;
import com.bjb.vr.common.dto.SysTenant;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.common.service.SysTenantService;
import com.bjb.vr.common.vo.SysTenantVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0.0
 * @description:租户管理
 * @author: caihaibo
 * @createDate: 2022/8/5
 */
@RestController
@RequestMapping("/api/operation/v1")
public class SysTenantController {

	@Autowired
	SysTenantService sysTenantService;

	/**
	 * 客户配置管理-获取租户树形列表
	 * @return
	 */
	@RequestMapping("/selectSysTenantTreeList")
	public BaseResult<List<SysTenantVo>> selectSysTenantTreeList(){
		List<SysTenantVo> sysTenantVoList = sysTenantService.selectSysTenantTreeList();
		return CommonResult.Ok().setResult(sysTenantVoList);
	}

	/**
	 * 通过租户id获取租户信息
	 * @param sysTenantAo
	 * @return
	 */
	@RequestMapping("/selectOneSysTenantByTenantId")
	public BaseResult<SysTenant> selectOneSysTenantByTenantId(SysTenantAo sysTenantAo){
		Assert.notNull(sysTenantAo.getTenantId(),"租户id不能为空");
		SysTenant sysTenant = sysTenantService.selectOneSysTenantByTenantId(sysTenantAo.getTenantId());
		return CommonResult.Ok().setResult(sysTenant);
	}
}
